//
//  OmegaIISystem.m
//  blackjack
//
//  Created by Thi Nguyen Tran on 3/17/10.
//  Copyright 2010 Epsilon. All rights reserved.
//

#import "OmegaIISystem.h"

@interface OmegaIISystem (Private)

int numberOfCount_;
int sumOfResult_;
float result_;
int trace_[100];
int undo_;
- (void)changeLabel;

@end


@implementation OmegaIISystem
@synthesize undoButton, loIIButton, hiIIButton, loIButton, hiIButton, backButton, newdeckButton;
@synthesize numberCounting, countingResult;
@synthesize delegate;
- (IBAction)hiIButtonTouched {
	sumOfResult_++;
	numberOfCount_++;
	
	trace_[undo_] = -1;
	undo_++;
	[self changeLabel];
	
}
- (IBAction)hiIIButtonTouched {
	sumOfResult_ += 2;
	numberOfCount_++;
	
	trace_[undo_] = -2;
	undo_++;
	[self changeLabel];
	
}
- (IBAction)loIButtonTouched {
	sumOfResult_ -= 1;
	numberOfCount_++;
	
	trace_[undo_] = 1;
	undo_++;
	[self changeLabel];
}
- (IBAction)loIIButtonTouched {
	sumOfResult_ -= 2;
	numberOfCount_++;
	
	trace_[undo_] = 2;
	undo_++;
	[self changeLabel];
}
- (IBAction)undoButtonTouched {
	if (undo_ != 0)
	{
		numberOfCount_ --;
		
		undo_--;
		sumOfResult_ += trace_[undo_];
	}
	[self changeLabel];
}
- (IBAction)newdeckButtonTouched {
	numberOfCount_ = 0;
	sumOfResult_ = 0;
	undo_ = 0;
	[self changeLabel];
	
}
- (IBAction)backButtonTouched 
{
	[delegate backToMainMenu];
}

- (void)changeLabel
{
	[countingResult setText:[NSString stringWithFormat:@"%d", sumOfResult_]];
	[numberCounting setText:[NSString stringWithFormat:@"%d", numberOfCount_]];
}

- (void)viewDidLoad {
	NSLog(@"Omega system did load.");
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
